package com.smart.modules.genealogy.service.impl;

import com.smart.system.common.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.smart.modules.genealogy.mapper.PersonRelationshipMapper;
import com.smart.modules.genealogy.domain.PersonRelationship;
import com.smart.modules.genealogy.service.IPersonRelationshipService;

/**
 * 人员关系Service业务层处理
 */
@Service
public class PersonRelationshipServiceImpl implements IPersonRelationshipService
{
    @Autowired
    private PersonRelationshipMapper personRelationshipMapper;

    /**
     * 查询人员关系
     *
     * @param personId 人员关系主键
     * @return 人员关系
     */
    @Override
    public PersonRelationship selectPersonRelationshipByPersonId(Long personId)
    {
        return personRelationshipMapper.selectPersonRelationshipByPersonId(personId);
    }

    /**
     * 查询人员关系列表
     *
     * @param personRelationship 人员关系
     * @return 人员关系
     */
    @Override
    public IPage<PersonRelationship> selectPersonRelationshipList(IPage<PersonRelationship> page,PersonRelationship personRelationship)
    {
        return personRelationshipMapper.selectPersonRelationshipList(page,personRelationship);
    }

    /**
     * 新增人员关系
     *
     * @param personRelationship 人员关系
     * @return 结果
     */
    @Override
    public int insertPersonRelationship(PersonRelationship personRelationship)
    {
        personRelationship.setCreateTime(DateUtils.getNowDate());
        return personRelationshipMapper.insertPersonRelationship(personRelationship);
    }

    /**
     * 修改人员关系
     *
     * @param personRelationship 人员关系
     * @return 结果
     */
    @Override
    public int updatePersonRelationship(PersonRelationship personRelationship)
    {
        personRelationship.setUpdateTime(DateUtils.getNowDate());
        return personRelationshipMapper.updatePersonRelationship(personRelationship);
    }

    /**
     * 批量删除人员关系
     *
     * @param personIds 需要删除的人员关系主键
     * @return 结果
     */
    @Override
    public int deletePersonRelationshipByPersonIds(Long[] personIds)
    {
        return personRelationshipMapper.deletePersonRelationshipByPersonIds(personIds);
    }

    /**
     * 删除人员关系信息
     *
     * @param personId 人员关系主键
     * @return 结果
     */
    @Override
    public int deletePersonRelationshipByPersonId(Long personId)
    {
        return personRelationshipMapper.deletePersonRelationshipByPersonId(personId);
    }
}
